//test_demo.c 
#include <stdio.h> 
#include <stdlib.h> 
#include <fcntl.h> 
#include <unistd.h> 
#include <sys/ioctl.h> 
void showbuf(char *buf); 
int MAX_LEN=32; 
int main() 
{ 
int fd; 
int i; 
char buf[255]; 
for(i=0;i<MAX_LEN;i++) 
{buf[i]=i;} 
fd=open("/dev/evan",O_RDWR);
if(fd<0) 
{ 
printf("######demodriver drivers open failed!!######\n"); 
return(-1); 
} 
printf("######demodriver drivers open success!!######\n"); 
printf("write %d bytes data to /dev/evan \n",MAX_LEN); 
showbuf(buf); 
write(fd,buf,MAX_LEN); 
printf("Read %d bytes data from /dev/evan \n",MAX_LEN); 
read(fd,buf,MAX_LEN); 
showbuf(buf); 
ioctl(fd,1,NULL); 
close(fd); 
return 0; 
} 
void showbuf(char *buf) 
{ 
int i,j=0; 
for(i=0;i<MAX_LEN;i++) 
{ 
if(i%4==0) printf("\n%4d:",j++); 
printf("%4d",buf[i]); 
} 
printf("\n*********************************\n"); 
}